package org.jeecg.modules.sxaq.utils;

import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.exceptions.ClientException;
import org.jeecg.common.util.DySmsEnum;
import org.jeecg.common.util.DySmsHelper;
import org.jeecg.modules.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SmsUtils {

    @Autowired
    private ISysUserService sysUserService;

    public void sendSms(String member, String exception) {
        JSONObject obj = new JSONObject();
        obj.put("member", member);
        obj.put("exception", exception);
        List<String> phones =  sysUserService.queryUserBySmsPush();
        try {
            DySmsHelper.sendSms(String.format("%s", String.join(",", phones)), obj, DySmsEnum.ANR_TEMPLATE_CODE);
        } catch (ClientException e) {
            e.printStackTrace();
        }

    }
}
